import { defineStore } from 'pinia'
import { ref } from 'vue'
interface User {
  userName: string
  password: string
  auth: string[]
  token: string
}
export const userStore = defineStore(
  'user',
  () => {
    const userInfo = ref<User>({
      userName: '',
      password: '',
      auth: [],
      token: '',
    })

    const setUserInfo = (user: User) => {
      userInfo.value = user
    }

    return {
      userInfo,
      setUserInfo,
    }
  },
  {
    persist: {
      storage: localStorage,
      pick: ['userInfo'],
    },
  }
)
